home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / java / awt / Scrollbar.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  6.9 KB  |  366 lines

  1. package java.awt;
  2.  
  3. import java.awt.event.AdjustmentEvent;
  4. import java.awt.event.AdjustmentListener;
  5. import java.awt.peer.ScrollbarPeer;
  6. import java.io.IOException;
  7. import java.io.ObjectInputStream;
  8. import java.io.ObjectOutputStream;
  9. import java.util.EventListener;
  10. import javax.accessibility.Accessible;
  11. import javax.accessibility.AccessibleContext;
  12. import javax.accessibility.AccessibleState;
  13.  
  14. public class Scrollbar extends Component implements Adjustable, Accessible {
  15.    public static final int HORIZONTAL = 0;
  16.    public static final int VERTICAL = 1;
  17.    int value;
  18.    int maximum;
  19.    int minimum;
  20.    int visibleAmount;
  21.    int orientation;
  22.    int lineIncrement;
  23.    int pageIncrement;
  24.    transient boolean isAdjusting;
  25.    transient AdjustmentListener adjustmentListener;
  26.    private static final String base = "scrollbar";
  27.    private static int nameCounter = 0;
  28.    private static final long serialVersionUID = 8451667562882310543L;
  29.    private int scrollbarSerializedDataVersion;
  30.  
  31.    private static native void initIDs();
  32.  
  33.    public Scrollbar() throws HeadlessException {
  34.       this(1, 0, 10, 0, 100);
  35.    }
  36.  
  37.    public Scrollbar(int var1) throws HeadlessException {
  38.       this(var1, 0, 10, 0, 100);
  39.    }
  40.  
  41.    public Scrollbar(int var1, int var2, int var3, int var4, int var5) throws HeadlessException {
  42.       this.lineIncrement = 1;
  43.       this.pageIncrement = 10;
  44.       this.scrollbarSerializedDataVersion = 1;
  45.       GraphicsEnvironment.checkHeadless();
  46.       switch (var1) {
  47.          case 0:
  48.          case 1:
  49.             this.orientation = var1;
  50.             this.setValues(var2, var3, var4, var5);
  51.             return;
  52.          default:
  53.             throw new IllegalArgumentException("illegal scrollbar orientation");
  54.       }
  55.    }
  56.  
  57.    String constructComponentName() {
  58.       synchronized(this.getClass()) {
  59.          return "scrollbar" + nameCounter++;
  60.       }
  61.    }
  62.  
  63.    public void addNotify() {
  64.       synchronized(this.getTreeLock()) {
  65.          if (this.peer == null) {
  66.             this.peer = this.getToolkit().createScrollbar(this);
  67.          }
  68.  
  69.          super.addNotify();
  70.       }
  71.    }
  72.  
  73.    public int getOrientation() {
  74.       return this.orientation;
  75.    }
  76.  
  77.    public void setOrientation(int var1) {
  78.       synchronized(this.getTreeLock()) {
  79.          if (var1 == this.orientation) {
  80.             return;
  81.          }
  82.  
  83.          switch (var1) {
  84.             case 0:
  85.             case 1:
  86.                this.orientation = var1;
  87.                if (this.peer != null) {
  88.                   this.removeNotify();
  89.                   this.addNotify();
  90.                   this.invalidate();
  91.                }
  92.                break;
  93.             default:
  94.                throw new IllegalArgumentException("illegal scrollbar orientation");
  95.          }
  96.       }
  97.  
  98.       if (this.accessibleContext != null) {
  99.          this.accessibleContext.firePropertyChange("AccessibleState", var1 == 1 ? AccessibleState.HORIZONTAL : AccessibleState.VERTICAL, var1 == 1 ? AccessibleState.VERTICAL : AccessibleState.HORIZONTAL);
  100.       }
  101.  
  102.    }
  103.  
  104.    public int getValue() {
  105.       return this.value;
  106.    }
  107.  
  108.    public void setValue(int var1) {
  109.       this.setValues(var1, this.visibleAmount, this.minimum, this.maximum);
  110.    }
  111.  
  112.    public int getMinimum() {
  113.       return this.minimum;
  114.    }
  115.  
  116.    public void setMinimum(int var1) {
  117.       this.setValues(this.value, this.visibleAmount, var1, this.maximum);
  118.    }
  119.  
  120.    public int getMaximum() {
  121.       return this.maximum;
  122.    }
  123.  
  124.    public void setMaximum(int var1) {
  125.       if (var1 == Integer.MIN_VALUE) {
  126.          var1 = -2147483647;
  127.       }
  128.  
  129.       if (this.minimum >= var1) {
  130.          this.minimum = var1 - 1;
  131.       }
  132.  
  133.       this.setValues(this.value, this.visibleAmount, this.minimum, var1);
  134.    }
  135.  
  136.    public int getVisibleAmount() {
  137.       return this.getVisible();
  138.    }
  139.  
  140.    /** @deprecated */
  141.    @Deprecated
  142.    public int getVisible() {
  143.       return this.visibleAmount;
  144.    }
  145.  
  146.    public void setVisibleAmount(int var1) {
  147.       this.setValues(this.value, var1, this.minimum, this.maximum);
  148.    }
  149.  
  150.    public void setUnitIncrement(int var1) {
  151.       this.setLineIncrement(var1);
  152.    }
  153.  
  154.    /** @deprecated */
  155.    @Deprecated
  156.    public synchronized void setLineIncrement(int var1) {
  157.       int var2 = var1 < 1 ? 1 : var1;
  158.       if (this.lineIncrement != var2) {
  159.          this.lineIncrement = var2;
  160.          ScrollbarPeer var3 = (ScrollbarPeer)this.peer;
  161.          if (var3 != null) {
  162.             var3.setLineIncrement(this.lineIncrement);
  163.          }
  164.  
  165.       }
  166.    }
  167.  
  168.    public int getUnitIncrement() {
  169.       return this.getLineIncrement();
  170.    }
  171.  
  172.    /** @deprecated */
  173.    @Deprecated
  174.    public int getLineIncrement() {
  175.       return this.lineIncrement;
  176.    }
  177.  
  178.    public void setBlockIncrement(int var1) {
  179.       this.setPageIncrement(var1);
  180.    }
  181.  
  182.    /** @deprecated */
  183.    @Deprecated
  184.    public synchronized void setPageIncrement(int var1) {
  185.       int var2 = var1 < 1 ? 1 : var1;
  186.       if (this.pageIncrement != var2) {
  187.          this.pageIncrement = var2;
  188.          ScrollbarPeer var3 = (ScrollbarPeer)this.peer;
  189.          if (var3 != null) {
  190.             var3.setPageIncrement(this.pageIncrement);
  191.          }
  192.  
  193.       }
  194.    }
  195.  
  196.    public int getBlockIncrement() {
  197.       return this.getPageIncrement();
  198.    }
  199.  
  200.    /** @deprecated */
  201.    @Deprecated
  202.    public int getPageIncrement() {
  203.       return this.pageIncrement;
  204.    }
  205.  
  206.    public void setValues(int var1, int var2, int var3, int var4) {
  207.       int var5;
  208.       synchronized(this) {
  209.          if (var3 == Integer.MAX_VALUE) {
  210.             var3 = 2147483646;
  211.          }
  212.  
  213.          if (var4 <= var3) {
  214.             var4 = var3 + 1;
  215.          }
  216.  
  217.          long var7 = (long)var4 - (long)var3;
  218.          if (var7 > 2147483647L) {
  219.             var7 = 2147483647L;
  220.             var4 = var3 + (int)var7;
  221.          }
  222.  
  223.          if (var2 > (int)var7) {
  224.             var2 = (int)var7;
  225.          }
  226.  
  227.          if (var2 < 1) {
  228.             var2 = 1;
  229.          }
  230.  
  231.          if (var1 < var3) {
  232.             var1 = var3;
  233.          }
  234.  
  235.          if (var1 > var4 - var2) {
  236.             var1 = var4 - var2;
  237.          }
  238.  
  239.          var5 = this.value;
  240.          this.value = var1;
  241.          this.visibleAmount = var2;
  242.          this.minimum = var3;
  243.          this.maximum = var4;
  244.          ScrollbarPeer var9 = (ScrollbarPeer)this.peer;
  245.          if (var9 != null) {
  246.             var9.setValues(var1, this.visibleAmount, var3, var4);
  247.          }
  248.       }
  249.  
  250.       if (var5 != var1 && this.accessibleContext != null) {
  251.          this.accessibleContext.firePropertyChange("AccessibleValue", var5, var1);
  252.       }
  253.  
  254.    }
  255.  
  256.    public boolean getValueIsAdjusting() {
  257.       return this.isAdjusting;
  258.    }
  259.  
  260.    public void setValueIsAdjusting(boolean var1) {
  261.       boolean var2;
  262.       synchronized(this) {
  263.          var2 = this.isAdjusting;
  264.          this.isAdjusting = var1;
  265.       }
  266.  
  267.       if (var2 != var1 && this.accessibleContext != null) {
  268.          this.accessibleContext.firePropertyChange("AccessibleState", var2 ? AccessibleState.BUSY : null, var1 ? AccessibleState.BUSY : null);
  269.       }
  270.  
  271.    }
  272.  
  273.    public synchronized void addAdjustmentListener(AdjustmentListener var1) {
  274.       if (var1 != null) {
  275.          this.adjustmentListener = AWTEventMulticaster.add(this.adjustmentListener, var1);
  276.          this.newEventsOnly = true;
  277.       }
  278.    }
  279.  
  280.    public synchronized void removeAdjustmentListener(AdjustmentListener var1) {
  281.       if (var1 != null) {
  282.          this.adjustmentListener = AWTEventMulticaster.remove(this.adjustmentListener, var1);
  283.       }
  284.    }
  285.  
  286.    public synchronized AdjustmentListener[] getAdjustmentListeners() {
  287.       return (AdjustmentListener[])this.getListeners(AdjustmentListener.class);
  288.    }
  289.  
  290.    public <T extends EventListener> T[] getListeners(Class<T> var1) {
  291.       Object var2 = null;
  292.       if (var1 == AdjustmentListener.class) {
  293.          AdjustmentListener var3 = this.adjustmentListener;
  294.          return (T[])AWTEventMulticaster.getListeners(var3, var1);
  295.       } else {
  296.          return (T[])super.getListeners(var1);
  297.       }
  298.    }
  299.  
  300.    boolean eventEnabled(AWTEvent var1) {
  301.       if (var1.id == 601) {
  302.          return (this.eventMask & 256L) != 0L || this.adjustmentListener != null;
  303.       } else {
  304.          return super.eventEnabled(var1);
  305.       }
  306.    }
  307.  
  308.    protected void processEvent(AWTEvent var1) {
  309.       if (var1 instanceof AdjustmentEvent) {
  310.          this.processAdjustmentEvent((AdjustmentEvent)var1);
  311.       } else {
  312.          super.processEvent(var1);
  313.       }
  314.    }
  315.  
  316.    protected void processAdjustmentEvent(AdjustmentEvent var1) {
  317.       AdjustmentListener var2 = this.adjustmentListener;
  318.       if (var2 != null) {
  319.          var2.adjustmentValueChanged(var1);
  320.       }
  321.  
  322.    }
  323.  
  324.    protected String paramString() {
  325.       return super.paramString() + ",val=" + this.value + ",vis=" + this.visibleAmount + ",min=" + this.minimum + ",max=" + this.maximum + (this.orientation == 1 ? ",vert" : ",horz") + ",isAdjusting=" + this.isAdjusting;
  326.    }
  327.  
  328.    private void writeObject(ObjectOutputStream var1) throws IOException {
  329.       var1.defaultWriteObject();
  330.       AWTEventMulticaster.save(var1, "adjustmentL", this.adjustmentListener);
  331.       var1.writeObject((Object)null);
  332.    }
  333.  
  334.    private void readObject(ObjectInputStream var1) throws ClassNotFoundException, IOException, HeadlessException {
  335.       GraphicsEnvironment.checkHeadless();
  336.       var1.defaultReadObject();
  337.  
  338.       Object var2;
  339.       while(null != (var2 = var1.readObject())) {
  340.          String var3 = ((String)var2).intern();
  341.          if ("adjustmentL" == var3) {
  342.             this.addAdjustmentListener((AdjustmentListener)var1.readObject());
  343.          } else {
  344.             var1.readObject();
  345.          }
  346.       }
  347.  
  348.    }
  349.  
  350.    public AccessibleContext getAccessibleContext() {
  351.       if (this.accessibleContext == null) {
  352.          this.accessibleContext = new AccessibleAWTScrollBar(this);
  353.       }
  354.  
  355.       return this.accessibleContext;
  356.    }
  357.  
  358.    static {
  359.       Toolkit.loadLibraries();
  360.       if (!GraphicsEnvironment.isHeadless()) {
  361.          initIDs();
  362.       }
  363.  
  364.    }
  365. }
  366.